import React from 'react'
import styles from './style.less'

import successImg from '../../static/images/success.png';
import errorImg from '../../static/images/error.png';


class Modal extends React.Component{
  constructor(props){
    super(props);

  }

  render(){
    let { visible, children, onOk, type } = this.props;
    let style = { display: 'none' };
    if ( visible ) style.display = 'flex';
    let img = successImg;
    if ( type === 'error' ) img = errorImg;

    return (
      <div style={ style } className={ styles.modal } >
        <div className={ styles.modalMain  }>
          <img src={ img } alt="icon"/>
          { children }
        </div>

        <div className={ styles.modalButton }>
          <div className={ styles.buttonNormal } onClick={ onOk }>
            完成
          </div>
        </div>
      </div>
    )
  }
}

export default Modal;